home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boosters.arc / COPYBLK.ASM < prev    next >
Assembly Source File  |  1985-11-09  |  2KB  |  106 lines

  1. ;************************************************
  2. ;
  3. ;       Procedure COPYBLK ( X1 : ColumnType;
  4. ;                           Y1 : RowType;
  5. ;                           X2 : ColumnType;
  6. ;                           Y2 : RowType;
  7. ;                           X3 : ColumnType;
  8. ;                           Y3 : RowType );
  9. ;
  10. ;       Copies block from screen at X1,Y1,X2,Y2
  11. ;                                to X3,Y3
  12. ;************************************************
  13. CopyBlk proc    near
  14.         push    bp
  15.     mov    bp,sp
  16.     push    ds
  17. ;
  18. ;***  Determine monitor type
  19. ;
  20.     mov    bx,449h
  21.     xor    ax,ax
  22.     mov    ds,ax
  23.     mov    al,[bx]
  24.     cmp    al,7        ; Monochrome?
  25.     jne    graphx
  26.     mov    dx,0B000h
  27.     jmp    c001
  28. graphx:
  29.     mov    dx,03DAh    ; for IBM CGA,
  30. VR:    in    al,dx        ; we must do this
  31.     and    al,1000b    ; so we won't see
  32.     jz    vr        ; snow
  33.     mov    dx,0B800h
  34. c001:    push    dx
  35. ;
  36. ;***  Compute X,Y addresses
  37. ;
  38.     mov    bx,[bp+12]    ;  Y1
  39.         dec     bx              ;  (Y1-1)
  40.     mov    dx,bx        ;  Save in DX
  41.     mov    cl,7
  42.     shl    dx,cl        ;  (Y1-1) * 128
  43.     mov    cl,5
  44.     shl    bx,cl        ;  (Y1-1) *  32
  45.     add    bx,dx        ;  (Y1-1) * 160
  46.     mov    ax,[bp+14]    ;  X1
  47.     dec    ax        ;  (X1-1)
  48.     shl    ax,1        ;  2 * (X1-1)
  49.     add    bx,ax        ;  X1,Y1 offset in BX
  50.     mov    si,bx        ;  Move to SI
  51.     pop    ds        ;  DS:SI --> X1,Y1
  52.     push    ds
  53. ;
  54.     mov    bx,[bp+04]    ;  Y3
  55.         dec     bx              ;  (Y3-1)
  56.     mov    dx,bx        ;  Save in DX
  57.     mov    cl,7
  58.     shl    dx,cl        ;  (Y3-1) * 128
  59.     mov    cl,5
  60.     shl    bx,cl        ;  (Y3-1) *  32
  61.     add    bx,dx        ;  (Y3-1) * 160
  62.     mov    ax,[bp+06]    ;  X3
  63.     dec    ax        ;  (X3-1)
  64.     shl    ax,1        ;  2 * (X3-1)
  65.     add    bx,ax        ;  X3,Y3 in BX
  66.     mov    di,bx        ;  move to DI
  67.     pop    es        ;  ES:DI --> X3,Y3
  68. ;
  69. ;
  70. ;*** Compute number of lines to move
  71. ;
  72.     mov    ax,[bp+12]    ; Y1 into AX
  73.     mov    dx,[bp+08]    ; Y2 into DX
  74.         sub     dx,ax           ; DX = DX - AX
  75.     inc    dx        ; DX = Num of lines
  76. ;
  77. ;
  78. ;*** Compute length of each move
  79. ;
  80.     mov    ax,[bp+14]    ;  X1 into AX
  81.     mov    cx,[bp+10]    ;  X2 into CX
  82.     sub    cx,ax        ;  CX = X1 - X2
  83.     inc    cx        ;  CX = line length
  84. ;
  85. ;*** Move block
  86. ;
  87. MOVER:    push    cx        ; save line length
  88.         cld                     ; forward move
  89. rep    movsw            ; move a line
  90.     pop    cx        ; restore line length
  91.     dec    dx        ; decrement Num lines
  92.     jz    DONE        ; Done if zero
  93.     mov    bx,cx        ; otherwise continue
  94.     shl    bx,1
  95.     mov    ax,160
  96.     sub    ax,bx
  97.     add    si,ax        ; adjust pointers
  98.     add    di,ax
  99.     jmp    MOVER        ; etc.
  100. ;
  101. DONE:   pop     ds
  102.         mov     sp,bp
  103.         pop     bp
  104.     ret    12        ; clear parameters
  105. CopyBlk endp
  106.